
package Messages;

import java.io.IOException;
import java.sql.SQLException;

import Server.SQLConnection;

import ocsf.server.ConnectionToClient;
/**
 * This class implements the delete Coating from DB
 *   @author Shlomit Yosfan
 * @author Nofar Sutliman
 */
public class MessageDeleteCoating {
	
	private ConnectionToClient client ;
	private String[] str; 
/**
 * constructor of this class
 * @param str
 * @param client
 */
	public MessageDeleteCoating(String[] str, ConnectionToClient client) {
		this.client= client ;
		this.str= str; 	
	}
	/**
	 * This method delete Coating from the DB 
	 * @throws SQLException
	 * @throws IOException
	 */
	public void DeleteCoating() throws SQLException, IOException{
		SQLConnection sc = new SQLConnection();

		java.sql.PreparedStatement ps=sc.getConnection().prepareStatement("DELETE FROM db.coating where CoatingID = ?;");
		ps.setString(1,str[1]);
		ps.executeUpdate();
		ps.close();                                                         
		client.sendToClient("DeleteCoating");
	}
}
